﻿using BMS.Visitor.DL;
using BMS.Visitor.Model.Entities;
using FirstFloor.ModernUI.Windows.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Common.Logging;

namespace BMS.VISITORS.DESKTOP.Content
{
    /// <summary>
    /// Interaction logic for VisitorForm.xaml
    /// </summary>
    public partial class VisitorForm : UserControl
    {
        #region Properties
        ILog _log = null;
        IDataLogic<BMS.Visitor.Model.Entities.Visitor> visitorDataLogic = null;
        #endregion Properties

        #region Methods
        public VisitorForm()
        {
            InitializeComponent();
            this.Loaded += OnLoaded;
            
            _log = LogManager.GetLogger(GetType());
            // Lógica para almacenar un visitante
            visitorDataLogic = new VisitorDataLogic();
        }

        void OnLoaded(object sender, RoutedEventArgs e)
        {
            // Focus sobre el primer elemento del formulario
            //Keyboard.Focus(this.TextDocumentID);
        }

        private void ButtonConsult_Click(object sender, RoutedEventArgs e)
        {

            MessageBoxButton btn = MessageBoxButton.OK;

            try
            {
                ModernDialog.ShowMessage("Consultando la información del visitante", "Información", btn);

                //visitorDataLogic.
            }
            catch (Exception exc)
            {
                btn = MessageBoxButton.OK;
                ModernDialog.ShowMessage(exc.Message, "Error", btn);
            }
        }

        private void ButtonSave_Click(object sender, RoutedEventArgs e)
        {

            MessageBoxButton btn = MessageBoxButton.OK;

            try
            {
                visitorDataLogic.Save(
                    new BMS.Visitor.Model.Entities.Visitor()
                    {
                        //DocumentId = this.TextDocumentID.Text,
                        //Name = this.TextFirstName.Text,
                        //LastName = this.TextLastName.Text,
                        //Telephone = this.TextTelephone.Text,
                        //Genere = "M"
                    });

                ModernDialog.ShowMessage("Visitante almacenado de manera satisfactoria", "Información", btn);
            }
            catch (Exception exc)
            {
                btn = MessageBoxButton.OK;
                ModernDialog.ShowMessage(exc.Message, "Error", btn);
            }
        }

        private void ButtonTransfer_Click(object sender, RoutedEventArgs e)
        {
            MessageBoxButton btn = MessageBoxButton.OKCancel;
            ModernDialog.ShowMessage("Desea transferir el visitante?", "Confirmación", btn);

            new ModernDialog
            {
                Title = "Captura de Huella",
                Content = new VisitorFormFingerPrint()
            }.ShowDialog();

            // Lógica para transferir una huella
        }
        #endregion Methodss
    }
}
